<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tenants', function (Blueprint $table) {
            if (! Schema::hasColumn('tenants', 'service_fee_rate')) {
                $table->decimal('service_fee_rate', 5, 4)->default(0)->comment('服务费比例(0-1)')->after('tenant_type');
            }
        });
    }

    public function down(): void
    {
        Schema::table('tenants', function (Blueprint $table) {
            if (Schema::hasColumn('tenants', 'service_fee_rate')) {
                $table->dropColumn('service_fee_rate');
            }
        });
    }
};
